package cn.drenal.capcap.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 文件上传配置
 */
@Configuration
public class FileUploadConfig implements WebMvcConfigurer {

    /**
     * 文件上传路径
     */
    public static final String UPLOAD_PATH = System.getProperty("user.dir") + "/uploads/";

    /**
     * 文件访问路径
     */
    public static final String FILE_ACCESS_PATH = "/uploads/**";

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        registry.addResourceHandler(FILE_ACCESS_PATH)
                .addResourceLocations("file:" + UPLOAD_PATH);
    }
}